// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

/**
 * Created by Freeman on 2017/7/13.
 */
import Vue from 'vue'
import Bui from 'byted-toutiao-pc-base-components'
import 'byted-toutiao-pc-base-components/theme.css'
import { addWinLoadEvent, loadScript } from 'byted-toutiao-pc-business-components/src/js/utils'

import App from './page/p/App.vue'

Vue.config.productionTip = false

Vue.use(Bui)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  template: '<App/>',
  components: { App }
})

// 加载广告脚本
addWinLoadEvent(() => {
  setTimeout(function () {
    let picVersion = window.PAGE_SWITCH && window.PAGE_SWITCH.picVersion
    if (!picVersion) {
      const d = new Date()
      picVersion = d.getFullYear() + '' + (d.getMonth() + 1) + '' + d.getDate() + '_01'
    }
    var url = '//s3a.pstatp.com/toutiao/gallery_img/dist/img.min.js?ver=' + picVersion
    loadScript(url, function () {
      setTimeout(function () {
        window.ad$ && window.ad$.put()
      })
    })
  }, 1000)
})
